package classLoader;

import java.io.File;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

/**
 * @author
 * @date 2021年11月26日 22:11
 * @description
 */
public class MainTest {

    public static final String WATCH_PAC = System.getProperty("user.dir") + "/java_base/target/classes/classLoader";

    public static void main(String[] args) {
        ConcurrentHashMap<String, Long> filesInfo = new ConcurrentHashMap<>();

        File file = new File(WATCH_PAC);
        for (File watchFile : file.listFiles()) {
            filesInfo.put(watchFile.getName(), watchFile.lastModified());
            if (watchFile.getName().contains("TestModify")) {
                System.out.println(watchFile.lastModified());
            }
        }
        ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(5);
        scheduledExecutorService.scheduleAtFixedRate(new WatchDog(filesInfo), 0, 500, TimeUnit.MICROSECONDS);

    }

}
